#ifndef BUTTON_H_
#define BUTTON_H_

#ifdef _WIN32
#include <windows.h>
#endif

#include "GLee.h"
#include <GL/glu.h>

#include <string>
#include <boost/shared_ptr.hpp>

#include "geom.h"

class GLSLProgram;
class Scene;
class FreeTypeFont;
class GLTexture;

typedef enum
{
    IDLE,
    ACTIVE
} ButtonState;

class Button
{
public:
    Button(boost::shared_ptr<Scene> scene, const ButtonState state = IDLE);
    virtual ~Button(void);

    virtual void prepare(float dt);
    virtual void render(void);
    virtual bool initialize(void);

    void setPosition(const Vector3& v) { m_position = v; }
    Vector3 getPosition() const { return m_position; }

    void setDimension(const Dimension& d) { m_pixelsSize = d; }
    Dimension getDimension(void) const { return m_pixelsSize; }

    void setFontSize(const int size) { m_fontSize = size; }
    int getFontSize(void) const { return m_fontSize; }

    void setLabel(const std::string& label);
    std::string getLabel(void) { return m_label; }

    void setClicked(const bool clicked) { m_clicked = clicked; }
    bool isClicked(void) const { return m_clicked; }

    void setButtonState(const ButtonState buttonState);
    ButtonState getButtonState(void) const { return m_buttonState; }

protected:
    boost::shared_ptr<Scene> m_scene;
    Vector3 m_position;
    Dimension m_pixelsSize;
    int m_fontSize;
    std::string m_label;
    float m_labelLength;
    bool m_clicked;
    ButtonState m_buttonState;

    boost::shared_ptr<GLTexture> m_texture;
    GLuint m_vertexBuffer;
    GLuint m_texCoordBuffer;
    static GLSLProgram* m_shaderProgram;
    Vector3 m_positionInTexture;
    Dimension m_sizeInTexture;
    boost::shared_ptr<FreeTypeFont> m_font;

    Vector3 m_idleTexturePosition;
    Vector3 m_activeTexturePosition;

};

#endif // BUTTON_H_
